package Pre;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Demo {
    public static void main(String[] args) {
        File file = new File("E:\\IO流练习\\InoutStream\\002.txt");
        try {
            FileInputStream in  =new FileInputStream(file);
//            //读取一个字节
//            int read = in.read();
//            System.out.println(read);
//            //读取一个字节组
//            byte[] bytes = new byte[20];
//            int read1 = in.read(bytes);
//            System.out.println("dd"  + read1);
//            System.out.println(new String(bytes,0, read1));
//            //读取全部字符
//            byte[] bytes1 = in.readAllBytes();
//            System.out.println(new String(bytes1));
            //
            System.out.println("可用字节：" + in.available());
            byte[] bytes = new byte[in.available()];
            System.out.println(in.skip(2));
            int read = in.read(bytes);
            System.out.println(read);
            System.out.println(new String(bytes));

            //
//            int size = 0;
//            byte[] bytes = new byte[20];
//            String str = "";
//            while ((size = in.read(bytes)) != -1){
//                str += new String(bytes,0,size);
//            }
//            System.out.println(str.length());
//            System.out.println(str);
            in.close();
        }catch(IOException e){
            System.out.println(e.getMessage());
        }

    }
}
